/*
// server.js

const express = require("express");
const { exec } = require("child_process");
const path = require("path");

const app = express();
const port = 3000;

app.get("/openProtege", (req, res) => {
  // 实际安装 Protege 的路径
  const protegePath = "D:/Protege-5.5.0-win/Protege-5.5.0/Protege.exe";
  // 要打开的本体文件的绝对路径
  const ontologyFilePath = "D:/014/0A/SSL.owl";

  exec(`${protegePath} ${ontologyFilePath}`, (error) => {
    if (error) {
      console.error(`Error opening Protege: ${error.message}`);
      res.status(500).send("Internal Server Error");
    } else {
      console.log("Protege opened successfully");
      res.send("Protege opened successfully");
    }
  });
});

app.listen(port, () => {
  console.log(`Server is running at http://localhost:${port}`);
});
*/


const express = require('express');
const { exec } = require('child_process');

const app = express();
const port = 3000;

// 路由来打开 Protege 并加载文件
app.get('/openProtege', (req, res) => {
  const protegePath = '"D:/Protege-5.5.0-win/Protege-5.5.0/Protege.exe"'; // Protege 路径
  const filePath = '"D:/014/0A/SSL.owl"';  // 文件路径

  exec(`${protegePath} ${filePath}`, (error, stdout, stderr) => {
    if (error) {
      console.error(`执行的错误: ${error}`);
      return res.status(500).send('无法打开 Protege');
    }
    res.send('Protege 加载文件成功');
  });
});

app.listen(port, () => {
  console.log(`服务器运行在 http://localhost:${port}`);
});


